package com.market2.utils.converter.impl;

import com.market2.dto.ActionDto;
import com.market2.dto.ContratDto;
import com.market2.dto.StockOptionDto;
import com.market2.dto.SwapDto;
import com.market2.model.Action;
import com.market2.model.Contrat;
import com.market2.model.StockOption;
import com.market2.model.Swap;
import com.market2.utils.converter.Converter;

public class ContratConverter extends Converter
{
	@SuppressWarnings("unchecked") @Override
	public ContratDto convertTo(Object source)
	{
		if(source instanceof Action) {
			return (new ActionConverter()).convertTo(source);
		}
		
		if(source instanceof StockOption) {
			return (new StockOptionConverter()).convertTo(source);
		}
		
		if(source instanceof Swap) {
			return (new SwapConverter()).convertTo(source);
		}
		
		return null;
	}

	@SuppressWarnings("unchecked") @Override
	public Contrat convertFrom(Object source)
	{
		if(source instanceof ActionDto) {
			return (new ActionConverter()).convertFrom(source);
		}
		
		if(source instanceof StockOptionDto) {
			return (new StockOptionConverter()).convertFrom(source);
		}
		
		if(source instanceof SwapDto) {
			return (new SwapConverter()).convertFrom(source);
		}
		
		return null;
	}
}
